package com.sf.osms.dep.groovy;

import groovy.lang.GroovyClassLoader;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

import com.sf.osms.dep.domain.Router;

public class GroovyUtils {
	
	public static GroovyInterface invokeGroovy(String filePath) throws Exception{
		GroovyClassLoader gcl = new GroovyClassLoader(GroovyUtils.class.getClassLoader());
		Class parseClass = gcl.parseClass(new File(filePath));	
		return (GroovyInterface)parseClass.newInstance();
	}
	public static void main(String[] args) throws Exception{
		
		GroovyInterface invokeGroovy = invokeGroovy("D:/workspace/osms-dep/src/main/java/com/sf/osms/dep/groovy/KixBarTimeRepair.groovy");
		Map<String,String> map = new HashMap<String, String>();
		map.put("8", "2016/08/18");
		map.put("10","161");
		invokeGroovy.handleSimgleOrginalRouter(map);
		System.out.println(map);
		Router r = new Router();
		r.setAgentNetNum("");
		invokeGroovy.handleSimgleRouter(r);
		
		System.out.println(r.getNetNum() + "---" + r.getOperatorId());
	}
}
